
import 'package:flutter/material.dart';

class DrawerBody extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    _DrawerBodyState view = new _DrawerBodyState();

    return view;
  }
}

class _DrawerBodyState extends State<DrawerBody>  {
  String _name = 'yhy';

  List<String> _themeList = ['个人信息','考勤打卡','合同管理'];

  bool _isShowRetry = false;

  @override
  void initState() {
    super.initState();

  }


  Widget _buildDrawer() {
    return new UserAccountsDrawerHeader(
      onDetailsPressed: (){

      },
      accountName: new Text('$_name'),
      accountEmail: new Text('yuanhongyu@jianhuabm.com'),
      currentAccountPicture: new CircleAvatar(
        backgroundImage: new NetworkImage(
            'http://n.sinaimg.cn/translate/20170726/Zjd3-fyiiahz2863063.jpg'),
      ),
    );
  }

  Widget _buildOtherItem(String model) {
    return new InkWell(
      onTap: () {
//        Navigator.of(context).pop();
//        RouteUtil.route2ThemeList(context, '${model.id}');
      },
      child: new ListTile(
        trailing: new Icon(Icons.keyboard_arrow_right),
        title: new Text('${model}',
            style: new TextStyle(color: Colors.grey[700], fontSize: 18.0)),
      ),
    );
  }

  Widget _buildList(){
    return new MediaQuery.removePadding(
      context: context,
      // DrawerHeader consumes top MediaQuery padding.
      removeTop: true,
      child: new Expanded(
          child: new ListView(
            children: <Widget>[
              new Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: _themeList.map((String model) {
                  return _buildOtherItem(model);
                }).toList(),
              ),
            ],
          )),
    );
  }


  Widget _buildBody() {
    if (null != _themeList && _themeList.isNotEmpty) {
      return new Column(
        children: <Widget>[
          _buildDrawer(),
          new Divider(height: 1.0),
          _buildList()
        ],
      );
    }
    return null;
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.white,
      body: _buildBody(),
    );
  }

}

class DrawerPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.white,
      body: new DrawerBody(),
    );
  }
}
